<?php include('_init_.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>班尼頓寫真後台管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="../css/admin-body.css" rel="stylesheet" type="text/css" />
<link href="../css/ConAdd.css" rel="stylesheet" type="text/css" />
<link href="../css/uploadifyb.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../js/swfobject.js"></script>
<script type="text/javascript" src="../js/jquery.uploadify.v2.1.4.min.js"></script>
<script src="<?php echo constant('APP_JS_LIB_DIR');?>/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
// <![CDATA[
$(function(){
	$(".uploadifyupload").each(function(){
		
		var previous_img_id = $(this).attr('name');
		$(this).uploadify({
			'uploader': 'uploadify.swf',
			'cancelImg': 'cancel.png',
			'script': 'uploadify.php',
			'folder': 'files',
			'multi': false,
			'fileExt':'*.jpg;*.jpeg;*.gif;*.png',
				'fileDesc':'Image Files',
			'auto': true,
			'scriptData':{'<?php echo session_name();?>':'<?php echo session_id();?>','name':$(this).attr('name'),'responsetype':'sizeinfo'},
			'displayData': 'speed',
			'onComplete':function(event,queueID,fileObj,response,data){
				var responseObj = eval("("+response+")");
				var fileName = responseObj.name;
				$('#img_'+previous_img_id).attr('src','../img/tmp/' + fileName);
				$('#img_'+previous_img_id).show();
				$('input[name=ajaxf_'+previous_img_id+']').val(fileName);
				
			},
			'onError':function(event,queueId,fileObj,errorObj){
				alert(errorObj);
			}
		});
	});
});

function check_and_post_form()
{
	if ( $('.ck_cat_id:checked').length == 0 ) {
		alert('請選擇類别');
		window.scrollTo(0,0);
		return false;
	}
	var form = document.forms['page_form'];
	if ( form.name.value == '' ) {
		alert('請錄入產品名稱');
		window.scrollTo(0,0);
		return false;
	}
	if ( form.price.value == '' ) {
		alert('請錄入產品金額');
		window.scrollTo(0,0);
		return false;
	}
	form.submit();
	return false;
}
// ]]>
</script>
</head>

<body>
<?php include_once('admin-top.php');?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>" name="page_form"> 
<input type="hidden" name="id" value="<?php echo $GLOBALS['PAGE_FORM_DATA']['id'];?>"/>
<input type="hidden" name="act" value="save"/>
<div id="main" class="clearfix"><!-- star #main //-->
  
  <div id="contactall"><!-- star #main //-->
  <div id="tit" ><!-- star #tit //-->
    <ul>
    <li class="tit-a"><?php echo  $GLOBALS['PAGE_FORM_DATA']['id'] > 0 ?'修改':'新增'; ?>發燒商品</li>
    </ul>
  </div><!-- end #tit //-->
  <div id="contact" class="clearfix" ><!-- star #contact //-->
    <ul>
      <li>選擇分類： 
      <?php foreach($GLOBALS['GV_PRODUCT_CAT'] as $id=>$name):?>
       <input type="checkbox" <?php if ($GLOBALS['PAGE_FORM_DATA']['cat_id'] == $id):?>checked="checked"<?php endif;?>  name="cat_id" value="<?php echo $id;?>" class="ck_cat_id"/>&nbsp;<?php echo $name;?>
       &nbsp;&nbsp;
      <?php endforeach;?>
    </li>
    </ul>
    <ul>
      <li>產品名稱： <input name="name" type="text" class="keyina" placeholder="請輸入文章的標題" value="<?php echo $GLOBALS['PAGE_FORM_DATA']['name'];?>"/>
    </li>
    <li>產品金額： <input name="price" type="text" class="keyinb" placeholder="請輸入產品金額" value="<?php echo $GLOBALS['PAGE_FORM_DATA']['price'];?>"/>
    </li>
    </ul>
    <ul>
      <li>上傳產品圖片：</li>
    <li class="addcon-a">
    	<input class="uploadifyupload" type="file" name="image" id="imageswfupload"/> 
        <input name="ajaxf_image" type="hidden"/>
    </li>
    <li>
    <?php if ($GLOBALS['PAGE_FORM_DATA']['img_path']):?>
    <img  id="img_image" width="267" height="400" src="../img/<?php echo $GLOBALS['GV_IMAGE_PATH'].$GLOBALS['PAGE_FORM_DATA']['img_path'];?>"/>
    <?php else:?>
     <img src="#" id="img_image" width="267" height="400" style="display:none"/>
    <?php endif;?>
    </li>
    </ul>
  </div><!-- end #contact //-->
  <div id="ContactHtm" ><!-- star #contactHtm //-->
   <textarea class="ckeditor" name="content"><?php echo $GLOBALS['PAGE_FORM_DATA']['content'];?></textarea>
   </div><!-- end #contactHtm //-->
    <div id="ContactSet" ><!-- star #contactSet //-->
    <ul>
    <li class="cs-4"><a href="#" onclick="return check_and_post_form();">儲存</a> </li>
    </ul>
    </div><!-- end #contactSet //-->
  </div><!-- end #contactall //-->
</div><!-- end #main //-->
</form>
</body>
</html>